package com.sphd.beautysalon.adapters;

import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.beautysalon.base.RestaurantUrl;
import com.sphd.beautysalon.info.GreensInfo;
import com.sphd.beautysalon.utils.Constant;
import com.sphd.beautysalon.R;
import com.sphd.beautysalon.base.RestaurantsApplication;
import com.wzh.frame.utils.BigDisMailUtils;

import java.util.List;

/**
 * Created by Hu on 2016/11/16.
 */

public class FoodMenuAdapter extends BaseQuickAdapter<GreensInfo> {
    public FoodMenuAdapter(int layoutResId, List<GreensInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, GreensInfo greensInfo) {
        baseViewHolder
                .setVisible(R.id.foodtogo, greensInfo.getDishes_isosale()==1?true:false)
                .setText(R.id.food_name, greensInfo.getDishes_name())
                .setText(R.id.food_num, "No." + greensInfo.getDishes_no())
                .setText(R.id.food_vip_money, BigDisMailUtils.turnTrim(greensInfo.getDishes_vipprice(), Constant.DECIMAL_POINT))
                .setText(R.id.food_pay_money, BigDisMailUtils.turnTrim(greensInfo.getDishes_price(),Constant.DECIMAL_POINT));

        ImageView imageView = baseViewHolder.getView(R.id.food_image);
        setImage(imageView, greensInfo.getDishes_pic());
    }

    public void setImage(ImageView image, String url) {
        ImageLoader imageLoader = RestaurantsApplication.getImageLoader();
        ImageLoader.ImageListener listener = ImageLoader.getImageListener(image,
                R.mipmap.moren, R.mipmap.moren);
        imageLoader.get(RestaurantUrl.Httpimg + url, listener);
    }
}
